{extend name="layout/base"/}
{block name="content"}
<div >
    <div class="page-title">
        <h3 class="ui header">课程表</h3>
        <div class="page-title-right">
            <div class="tiny ui right floated buttons">
                <a class="ui button" href="{:url('getList')}">列表</a>
                <button type="text" class="ui teal button" data-title="课次管理" data-url="{:url('coursetimes')}" onclick="openBigWin(this)">课次管理</button>
                <button type="text" class="ui teal button" data-title="添加课程" data-url="{:url('savecourse')}" onclick="openBigWin(this)">添加单课</button>
                <button type="text" class="ui teal button" data-title="排课计划" data-url="{:url('schedule')}" onclick="openBigWin(this)">排课</button>
            </div>
        </div>
    </div>

    <div style="text-align: center; margin-top: 15px;">
        <div class="tiny ui buttons">
            <a class="ui teal basic button" href="{:url('calendar',['time'=>$time, 'type'=>'pre'])}">上一周</a>

            <a class="ui teal basic button simple dropdown item">
                {$week_days[1]}~{$week_days[7]}(第<?php echo date('W', strtotime($week_days[7]));?>周)
                <i class="dropdown icon"></i>
                <div class="menu">
                    {volist name='search_dates' id='sd'}
                    <div class="item" onclick="jumpDate('{$sd.time}')">{$sd.title}   <i class="dropdown right icon"><small> {:date('Y-m-d', $sd.time)}</small></i></div>
                    {/volist}
                </div>
            </a>

            <a class="ui teal basic button" href="{:url('calendar',['time'=>$time, 'type'=>'next'])}">下一周</a>
        </div>

        <div class="tiny ui buttons">
            {if $Request.param.showtype == 'section'}
            <a class="ui teal basic button" href="{:url('calendar',['time'=>$time])}">老师视图</a>
            {else/}
            <a class="ui teal basic button" href="{:url('calendar',['showtype'=>'section','time'=>$time])}">课次视图</a>
            {/if}
        </div>
    </div>
    <table class="ui celled table">
        <thead>
        <tr>
            <th> {if $Request.param.showtype == 'section'}课次{else/}老师{/if}</th>
            {volist name='week_days' id="d"}
            <th>周
                {switch name='key'}
                {case value="1"}一{/case}
                {case value="2"}二{/case}
                {case value="3"}三{/case}
                {case value="4"}四{/case}
                {case value="5"}五{/case}
                {case value="6"}六{/case}
                {case value="7"}日{/case}
                {/switch}
                <span style="font-weight: normal">(<?php echo date('m-d', strtotime($d));?>)</span>
            </th>
            {/volist}
        </tr>
        </thead>
        <tbody>
    {if $Request.param.showtype == 'section'}
        {foreach $times as $times_id=>$t_name }
        <tr>
            <td>{$t_name}</td>
            {volist name='week_days' id="d"}
            <td>
                {if isset($data[$times_id][$d])}
                {foreach $data[$times_id][$d] as $vo }
                {$vo.staff.name} {$vo.assistant?', '. $vo.assistant.name:''}
                ({$vo.clazz.name})
                {$vo.section_id?=$vo.section.title}
                <br>
                {/foreach}
                {/if}
            </td>
            {/volist}
        </tr>
        {/foreach}
    {else/}

        {foreach $teachers as $t_id=>$t_name }
        <tr>
            <td>{$t_name}</td>
            {volist name='week_days' id="d"}
            <td>
                {if isset($data[$t_id][$d])}
                {foreach $data[$t_id][$d] as $vo }
                {$vo.times.name}
                ({$vo.clazz.name})
                {$vo.section_id?=$vo.section.title}
                <br>
                {/foreach}
                {/if}
            </td>
            {/volist}
        </tr>
        {/foreach}

        {foreach $assistants as $t_id=>$t_name }
        <tr>
            <td>{$t_name} [助]</td>
            {volist name='week_days' id="d"}
            <td>
                {if isset($data[$t_id][$d])}
                {foreach $data[$t_id][$d] as $vo }
                {$vo.times.name}
                ({$vo.clazz.name})
                {$vo.section_id?=$vo.section.title}
                <br>
                {/foreach}
                {/if}
            </td>
            {/volist}
        </tr>
        {/foreach}


    {/if}
        </tbody>
    </table>
</div>
<script>
    function jumpDate(time, e, stop)
    {
        location.href="{:url('calendar')}?time=" + time;
    }
</script>
{/block}